package com.heiye.comment.biz.domain.mapper;

import com.heiye.comment.biz.domain.dataobject.CommentDO;
import com.heiye.comment.biz.model.bo.CommentBO;
import org.apache.ibatis.annotations.Param;

import java.util.List;

public interface CommentDOMapper {
    int deleteByPrimaryKey(Long id);

    int insert(CommentDO record);

    int insertSelective(CommentDO record);

    CommentDO selectByPrimaryKey(Long id);

    int updateByPrimaryKeySelective(CommentDO record);

    int updateByPrimaryKey(CommentDO record);

    /**
     * 根据评论 ID 批量查询
     *
     * @param commentIds
     * @return
     */
    List<CommentDO> selectByCommentId(@Param("commentIds") List<Long> commentIds);

    /**
     * 批量插入
     *
     * @param comments
     * @return
     */
    int batchInsert(@Param("comments") List<CommentBO> comments);

    /**
     * 查询评论游标分页数据
     *
     * @param quizId
     * @param cursor
     * @return
     */
    List<CommentDO> selectCursorPageList(@Param("quizId") Long quizId,
                                         @Param("cursor") Long cursor,
                                         @Param("bestCommentId") Long bestCommentId);

    /**
     * 查询最先发布的前 50 条评论
     *
     * @param quizId
     * @param bestCommentId
     * @return
     */
    List<CommentDO> selectTop50Comments(@Param("quizId") Long quizId,
                                        @Param("bestCommentId") Long bestCommentId);

    /**
     * 批量删除评论
     *
     * @param commentIds
     * @return
     */
    int deleteByIds(@Param("commentIds") List<Long> commentIds);


    /**
     * 根据 reply_comment_id 查询
     *
     * @param commentIds
     * @return
     */
    List<CommentDO> selectByReplyCommentId(@Param("commentIds") List<Long> commentIds);

    /**
     * 更新评论为最佳
     *
     * @param commentId
     * @return
     */
    int updateIsBest(@Param("commentId") Long commentId);

    /**
     * 查询最佳回答
     *
     * @param quizId
     * @return
     */
    CommentDO selectBestCommentByQuizId(@Param("quizId") Long quizId);

    /**
     * 取消最佳回答
     *
     * @param commentId
     * @return
     */
    int updateIsBestCancel(@Param("commentId") Long commentId);
}